package com.wanli.agent.homepage;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wanli.agent.R;
import com.wanli.agent.base.Adapter_ViewPager_Fragment;
import com.wanli.agent.base.BaseActivity;
import com.wanli.agent.base.BaseFragment;
import com.wanli.agent.widget.NoScrollViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class IncomeActivity extends BaseActivity {

    @BindView(R.id.viewPager)
    NoScrollViewPager viewPager;
    @BindView(R.id.ll_left)
    LinearLayout llLeft;
    @BindView(R.id.tv_share_money)
    TextView tvShareMoney;
    @BindView(R.id.tv_return_money)
    TextView tvReturnMoney;
    private List<String> mDataList;
    private Adapter_ViewPager_Fragment adapter_viewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_income);
        ButterKnife.bind(this);
        initView();
    }

    public void initView() {
        mDataList = new ArrayList<>();
        mDataList.add("分润收益");
        mDataList.add("返现收益");
        //ViewPager的适配器
        List<BaseFragment> fragmentList = new ArrayList<>();
        fragmentList.add(new IncomeShareFragment());
        fragmentList.add(new IncomeReturnFragment());
        adapter_viewPager = new Adapter_ViewPager_Fragment(getSupportFragmentManager(), fragmentList, mDataList);
        viewPager.setAdapter(adapter_viewPager);
        viewPager.setOffscreenPageLimit(2);
    }


    @OnClick({R.id.ll_left, R.id.tv_share_money, R.id.tv_return_money})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_left:
                finish();
                break;
            case R.id.tv_share_money:
                tvShareMoney.setTextColor(getResources().getColor(R.color.theme_color));
                tvShareMoney.setBackgroundResource(R.drawable.shape_left_conner_white4);
                tvReturnMoney.setTextColor(getResources().getColor(R.color.white));
                tvReturnMoney.setBackgroundResource(R.drawable.shape_right_conner_theme4);
                viewPager.setCurrentItem(0);
                break;
            case R.id.tv_return_money:
                tvShareMoney.setTextColor(getResources().getColor(R.color.white));
                tvShareMoney.setBackgroundResource(R.drawable.shape_left_conner_theme4);
                tvReturnMoney.setTextColor(getResources().getColor(R.color.theme_color));
                tvReturnMoney.setBackgroundResource(R.drawable.shape_right_conner_white4);
                viewPager.setCurrentItem(1);
                break;
        }
    }
}
